import Layout from '@/layout/index.vue'
import Home from '@/views/dashboard/index.vue'
import { ChartBar, HouseDamage, User } from '@vicons/fa'

// 基础路由 无需权限，总会注册到最终路由中
//默认有权限的路由都会展示到左侧的菜单中，如无需展示，添加isHidden = true 即可隐藏，
export const basicRoutes = [
  // 404页面
  {
    name: '404',
    path: '/404',
    component: () => import('@/views/error-page/404.vue'),
    isHidden: true,
  },
  {
    name: 'REDIRECT',
    path: '/redirect',
    component: Layout,
    isHidden: true,
    children: [
      {
        name: 'REDIRECT_NAME',
        path: '',
        component: () => import('@/views/redirect/index.vue'),
      },
    ],
  },
  //登录页面
  {
    name: 'LOGIN',
    path: '/login',
    component: () => import('@/views/login/index.vue'),
    isHidden: true,
    // 附加到路由上的路由元信息
    meta: {
      title: '登录页',
    },
  },
  // // Dashboard
  // {
  //   name: 'DASHBOARD',
  //   path: '/',
  //   component: Layout,
  //   redirect: '/home', //重定向 '/'会跳转到 '/home'
  //   // meta.title 和 meta.icon分别代表生成菜单项的文本和图标。
  //   meta: {
  //     title: 'Dashboard',
  //     icon: ChartBar,
  //   },
  //   children: [
  //     {
  //       name: 'HOME',
  //       path: 'home',
  //       component: Home,
  //       meta: {
  //         title: '首页',
  //         icon: HouseDamage,
  //       },
  //     },
  //   ],
  // },

  // 任务广场
  {
    name: '任务广场',
    path: '/',
    component: Layout,
    redirect: '/home', //重定向 '/'会跳转到 '/home'
    // meta.title 和 meta.icon分别代表生成菜单项的文本和图标。
    meta: {
      title: '任务广场',
      icon: ChartBar,
    },
    children: [
      {
        name: 'HOME',
        path: 'home',
        component: Home,
        // redirect: '/home/details',
        meta: {
          title: '首页',
          icon: HouseDamage,
        },
      },
      {
        name: 'task-details',
        path: 'details',
        component: () => import('@/views/details/index.vue'),
        meta: {
          title: '详情',
        },
        isHidden: true,
      },
      {
        name: 'task-mark',
        path: 'mark',
        component: () => import('@/views/mark/AppPoint copy.vue'),
        meta: {
          title: '标注',
        },
        isHidden: true,
      },
      {
        name: 'task-mark2',
        path: 'mark2',
        component: () => import('@/views/mark/AppPoint.vue'),
        meta: {
          title: '标注2',
        },
        isHidden: true,
      },
      {
        name: 'task-mark3',
        path: 'mark3',
        component: () => import('@/views/mark/Menu.vue'),
        meta: {
          title: '标注2',
        },
        isHidden: true,
      },
      {
        name: 'task-mark4',
        path: 'mark4',
        component: () => import('@/views/mark/Rectangle.vue'),
        meta: {
          title: '标注2',
        },
        isHidden: true,
      },
    ],
  },

  {
    name: 'TEST',
    path: '/history',
    component: Layout,
    redirect: '/history/tasks',
    meta: {
      title: '历史任务',
    },
    children: [
      {
        name: 'TASKS',
        path: 'tasks',
        component: () => import('@/views/history-page/index.vue'),
        meta: {
          title: '历史任务',
        },
      },
    ],
  },
  {
    name: 'PERSONAL-CENTER',
    path: '/personal-center',
    component: Layout,
    redirect: '/personal-center/settings',
    meta: {
      title: '个人中心',
      icon: User,
    },
    children: [
      {
        name: 'user-settings',
        path: 'settings',
        component: () => import('@/views/personal-center/index.vue'),
        meta: {
          title: '个人信息设置',
        },
      },
    ],
  },
  // {
  //   name: 'ERROR-PAGE',
  //   path: '/error-page',
  //   component: Layout,
  //   redirect: '/error-page/404',
  //   meta: {
  //     title: '错误页',
  //     icon: TimesCircle,
  //   },
  //   children: [
  //     {
  //       name: 'ERROR-404',
  //       path: '404',
  //       component: () => import('@/views/error-page/404.vue'),
  //       meta: {
  //         title: '404',
  //       },
  //     },
  //   ],
  // },
]

export const NOT_FOUND_ROUTE = {
  name: 'NOT_FOUND',
  path: '/:pathMatch(.*)*',
  redirect: '/404',
  isHidden: true,
}

const modules = import.meta.globEager('./modules/*.js')
const asyncRoutes = []
Object.keys(modules).forEach((key) => {
  asyncRoutes.push(...modules[key].default)
})
// 动态路由
export { asyncRoutes }
